package thinkinjava4.util;

import thinkinjava4.ch21_concurrency.DaemonThreadFactory;

import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class DaemonThreadPoolExecutor extends ThreadPoolExecutor {
    /**
     * 核心线程池的大小
     */
    private static final int CORE_POOL_SIZE = 0;
    /**
     * 线程池最大能创建的线程数目大小
     */
    private static final int MAXIMUM_POOL_SIZE = Integer.MAX_VALUE;
    /**
     * 线程存活时间
     */
    private static final long KEEP_ALIVE_TIME = 60L;

    public DaemonThreadPoolExecutor() {
        super(
                CORE_POOL_SIZE,
                MAXIMUM_POOL_SIZE,
                KEEP_ALIVE_TIME,
                TimeUnit.SECONDS,
                new SynchronousQueue<>(),
                new DaemonThreadFactory());
    }
}
